import { TagItem } from '../tag/interface';

export type FieldType =
  | 'single'
  | 'multiple'
  | 'textInput'
  | 'number'
  | 'numberRange'
  | 'datePicker'
  | 'dateRangePicker'
  | 'treeSingle'
  | 'treeMultiple'
  | 'customize';

export type FilterMode = 'startsWith' | 'endsWith' | 'contains' | 'more' | 'less' | 'equals' | 'rangeIn';

export type FilterTagItem = TagItem & { field: string | number };

export interface BaseItem {
  /**
   * @description 自定义弹层
   */
  [key: string]: any;
  /**
   * 过滤字段的显示值
   */
  label?: string;
  /**
   * 过滤字段，需要唯一
   */
  field: string | number;
  /**
   * 过滤字段配置项的类型
   */
  type: FieldType;
  /**
   * 过滤字段所属群组
   */
  group?: string;
  /**
   * 过滤字段是否禁用
   */
  disabled?: boolean;
  /**
   * @description 过滤字段的过滤内容
   */
  option?: Record<string, any>;
  /**
   * @description 默认过滤值
   */
  defaultValue?: any;
  /**
   * @description 过滤方式
   */
  mode?: FilterMode;
  /**
   * 推荐搜索栏展示
   */
  searchDisable?: boolean;
  /**
   * 禁用切换mode，true时不显示切换按钮
   */
  modeChangeDisable?: boolean;
}

export type FieldItem = BaseItem;

export interface FilterState {
  field: string | number; // 字段，用于tag显示唯一标识
  fieldInfo: FieldItem;
  type?: FieldType;
  filteredValue?: any;
  filterMode?: FilterMode;
  caseSensitive?: boolean;
}

export interface RecommendedValue {
  label: string;
  field: FieldType | string;
  value: string;
}
